package com.jtzc.aikf.file;

import dev.langchain4j.data.document.DocumentParser;
import dev.langchain4j.data.document.parser.TextDocumentParser;
import dev.langchain4j.data.document.parser.apache.pdfbox.ApachePdfBoxDocumentParser;
import org.springframework.stereotype.Component;

/**
 * @author wu chuang
 * @description
 */
@Component
public class DocumentLoadFactory {

    public DocumentLoader getDocumentLoader(String fileType){
        return new DefaultDocumentLoader(getDocumentParser(fileType));
    }

    private DocumentParser getDocumentParser(String fileType){
        if(fileType.equals("txe")){
            return new TextDocumentParser();
        }else if(fileType.equals("pdf")) {
            return new ApachePdfBoxDocumentParser();
        }
        return new TextDocumentParser();
    }
}
